#include <iostream>
#include <string>

int prime(int a) {
    int p = 1;
    if (a < 2) {
        p = 0;
    }
    else {
        for (int i = 2; i <= a/2 + 1; i++) {
            if (a % i == 0) {
                p = 0;
            }
        }
    }
    return p;
}

int main() {
    std::string a;
    std::getline(std::cin, a);

    a = a.replace(' ', '').replace('one', '1').replace('two', '2').replace('three', '3')
           .replace('four', '4').replace('five', '5').replace('six', '6').replace('seven', '7')
           .replace('eigth', '8').replace('nine', '9').replace('zero', '0');

    if (a.length() == 3 && a[0] >= '0' && a[0] <= '9' && a[1] >= '0' && a[1] <= '9' && 
        a[2] >= '0' && a[2] <= '9') {
        int num = std::stoi(a);
        int b = num;
        int c = num;
        if (prime(num) == 1) {
            std::cout << num << std::endl;
        }
        else {
            while (true) {
                b = b - 1;
                c = c + 1;
                if (prime(b) == 1) {
                    std::cout << b << std::endl;
                    break;
                }
                if (prime(c) == 1) {
                    std::cout << c << std::endl;
                    break;
                }
            }
        }
    }
    else {
        std::cout << "Wrong input" << std::endl;
    }

    return 0;
}